package com.weishi.project.training.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.weishi.framework.web.domain.AjaxResult;
import com.weishi.project.api.vo.SchemeDetailsDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.weishi.project.training.mapper.SchemeDetailsMapper;
import com.weishi.project.training.domain.SchemeDetails;
import com.weishi.project.training.service.ISchemeDetailsService;

/**
 * 训练方案子表Service业务层处理
 */
@Service
public class SchemeDetailsServiceImpl extends ServiceImpl<SchemeDetailsMapper, SchemeDetails> implements ISchemeDetailsService {

    @Autowired
    private SchemeDetailsMapper schemeDetailsMapper;

    /**
     * 查询训练方案子列表
     */
    @Override
    public List<SchemeDetails> selectSchemeDetailsList(SchemeDetails schemeDetails) {
        return schemeDetailsMapper.selectSchemeDetailsList(schemeDetails);
    }


    /**
     * 教练员端 -- 查询训练方案，组信息
     */
    @Override
    public AjaxResult getSchemeDetailsList(SchemeDetailsDTO schemeDetailsDTO) {
        List<SchemeDetails> list = list(Wrappers.<SchemeDetails>lambdaQuery()
                .eq(SchemeDetails::getTblSchemeId , schemeDetailsDTO.getTblSchemeId()));
        if(schemeDetailsDTO.getIndex() < list.size()){
            return AjaxResult.success(list.get(schemeDetailsDTO.getIndex()));
        }else{
            return AjaxResult.success();
        }
    }







}